<template>
	<view class="evaluate p-3">
		<LeftRight :data="leaveList" @ToDetail="getItemInfo">
			<template #bottom>
				<view class="buttom flex justify-between  font-sm align-center">
					<view></view>
					<view>
						<view class="btn" @click="goDetail">请假</view>
					</view>
				</view>
			</template>
		</LeftRight>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from 'vue'
	import {
		onShow
	} from "@dcloudio/uni-app"
	import LeftRight from '../../component/commonLayout/LeftRight.vue';
	import uniReq from '../../api/index.js'

	const leaveList = ref([])
	const itemId = ref('')

	const goDetail = () => {


		setTimeout(() => {
			uni.navigateTo({
				url: `/pages/leave/leave?id=${itemId.value}`
			})
		}, 20)
	}

	const getItemInfo = (item) => {
		console.log("item--------", item);
		itemId.value = item.id
		console.log("itemId.value--------", itemId.value);
	}

	const gitLeaveList = (status) => {
		uniReq({
			url: '/api/volunteer/activity/SelectActivityByUser',
			method: 'GET',
			data: {
				status: status,

			}
		}, e => {
			if (e.success) {
				console.log('e-------------', e.data.records)
				leaveList.value = e.data.records
				leaveList.value.forEach((item) => {
					item.responsibleimg = JSON.parse(item.responsibleimg)
					console.log('item.responsibleimg-------------', item.responsibleimg)
				})

			} else {
				uni.showToast({
					title: '获取请假列表信息失败',
					icon: 'none'
				})
			}
		})
	}
	onShow(()=>{
		gitLeaveList(1);
	})
	onMounted(() => {
		
	})
</script>

<style lang="scss" scoped>
	.evaluate {
		margin-top: -20rpx;

		.buttom {
			// margin: -20rpx 0;
		}

		.btn {
			padding: 10rpx 30rpx;
			border: 1rpx solid #ccc;
			border-radius: 50rpx;
		}
	}
</style>